package com.yitong.equipment

import android.app.Application
import android.content.Context
import com.blankj.utilcode.util.LogUtils
import com.luck.picture.lib.app.IApp
import com.luck.picture.lib.engine.PictureSelectorEngine
import com.maning.librarycrashmonitor.MCrashMonitor
import com.yitong.equipment.ext.isOpenLog
import com.yitong.equipment.view.PictureSelectorEngineImp

class App : Application(), IApp {

    companion object {
        lateinit var instance: App
    }

    override fun onCreate() {
        super.onCreate()
        instance = this
        isOpenLog = BuildConfig.DEBUG
//        initCrashMonitor()
    }


    private fun initCrashMonitor() {
        /**
         * 初始化日志系统
         * context :    上下文
         * isDebug :    是不是Debug模式,true:崩溃后显示自定义崩溃页面 ;false:关闭应用,不跳转奔溃页面(默认)
         * CrashCallBack : 回调执行
         */
        if (isOpenLog) {
            MCrashMonitor.init(this, true) { file -> //可以在这里保存标识，下次再次进入把日志发送给服务器
                LogUtils.d("CrashMonitor回调:" + file.absolutePath)
            }
        }
    }

    override fun getAppContext(): Context {
        return this
    }

    override fun getPictureSelectorEngine(): PictureSelectorEngine {
        return PictureSelectorEngineImp()
    }

}